package com.qidian.k12.util;

/**
 * @author 戴着假发的程序
 */
public class K12Result {
    private int status;
    private String msg;
    private Object data;

    public static K12Result ok(){
        K12Result ok = new K12Result();
        ok.setMsg(ResultStatus.OK_MSG);
        ok.setStatus(ResultStatus.OK);
        return  ok;
    }
    public static K12Result notFond(){
        K12Result ok = new K12Result();
        ok.setMsg(ResultStatus.NOT_FOUND_MSG);
        ok.setStatus(ResultStatus.NOT_FOUND);
        return  ok;
    }

    public static K12Result ok(Object data){
        K12Result ok = new K12Result();
        ok.setMsg(ResultStatus.OK_MSG);
        ok.setStatus(ResultStatus.OK);
        ok.setData(data);
        return  ok;
    }

    public static K12Result dataExists(){
        K12Result ok = new K12Result();
        ok.setMsg(ResultStatus.DATA_EXISTS_MSG);
        ok.setStatus(ResultStatus.DATA_EXISTS);
        return  ok;
    }

    public static K12Result error(){
        K12Result ok = new K12Result();
        ok.setMsg(ResultStatus.ERROR_MSG);
        ok.setStatus(ResultStatus.ERROR);
        return  ok;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public  static class ResultStatus {
        public  static  final int OK = 200;
        public static final int OK_PART = 205;
        public  static  final int ERROR = 500;
        public  static  final int NOT_FOUND = 404;
        public static final int DATA_EXISTS = 505;
        public  static  final String OK_MSG = "ok";
        public static final String OK_PART_MSG = "ok part";
        public  static final String ERROR_MSG = "error";
        public  static final String NOT_FOUND_MSG = "not found";
        public  static final String DATA_EXISTS_MSG = "data exists";
    }
}
